package routers

import (
	admin "ginadmin/app/admin/controller"
	"ginadmin/app/middleware"

	"github.com/gin-gonic/gin"
)

// 后台路由
func AdminRouter(v *gin.Engine) {

	router := v.Group("/admin")
	{
		//无需登录
		router.Any("/login", admin.PublicController{}.Login)
	}

	//加载后台中间件
	router.Use(middleware.AdminMiddleware())
	{
		//需要登录
		router.GET("/index", admin.IndexController{}.Index)     //后台框架页面
		router.GET("/index/main", admin.IndexController{}.Main) //后台主页展示
		router.GET("/index/menu", admin.IndexController{}.Menu) //获取菜单

		router.GET("/index/logout", admin.IndexController{}.Logout) //退出登录

		//菜单管理
		router.GET("/menu/index", admin.MenuController{}.MenuIndex)
		router.GET("/menu/getMenuList", admin.MenuController{}.GetMenuList)
		router.GET("/menu/postMenu", admin.MenuController{}.MenuPostPage)
		router.DELETE("/menu/delMenu", admin.MenuController{}.MenuDel)
		router.GET("/menu/select", admin.MenuController{}.GetSelect)
		router.POST("/menu/postMenu", admin.MenuController{}.MenuPost)

		//角色管理
		router.GET("/role/index", admin.RoleController{}.Index)
		router.GET("/role/getList", admin.RoleController{}.GetList)
		router.GET("/role/post", admin.RoleController{}.PostPage)
		router.POST("/role/post", admin.RoleController{}.Post)
		router.GET("/role/getMenu", admin.RoleController{}.GetMenu)
		router.DELETE("/role/delete", admin.RoleController{}.Delete)

		//管理员管理
		router.GET("/admin/index", admin.AdminController{}.Index)
		router.GET("/admin/getList", admin.AdminController{}.GetList)
		router.GET("/admin/post", admin.AdminController{}.PostPage)
		router.POST("/admin/post", admin.AdminController{}.Post)
		router.DELETE("/admin/delete", admin.AdminController{}.Delete)

	}

}
